package com.taxshare.seller.controller;

import cn.hutool.core.collection.CollUtil;
import com.taxshare.pvalidate.ParamValid;
import com.taxshare.response.beans.Response;
import com.taxshare.seller.service.CarProductionCompanyService;
import com.taxshare.seller.service.CarProductionPlaceService;
import com.taxshare.seller.view.dto.CarProductionCompanyDTO;
import com.taxshare.seller.view.dto.CarProductionPlaceDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author cxl
 * @date 2021/8/19 13:15
 */
@RestController
@RequestMapping("/carProductionCompany")
@Api(tags = "车辆生产企业信息")
public class CarProductionCompanyController {

    @Autowired
    CarProductionCompanyService carProductionCompanyService;

    @PostMapping("/add")
    @ApiOperation(value = "生产企业信息新增", notes = "生产企业信息")
    @ParamValid
    public Response addProductionCompany(@RequestBody @Valid CarProductionCompanyDTO companyDTO) {
        return carProductionCompanyService.addProductionCompany(companyDTO);
    }

    @GetMapping("/remove")
    @ApiOperation(value = "生产企业信息删除", notes = "生产企业信息")
    public Response removeProductionCompany(String[] ids) {

        return carProductionCompanyService.removeProductionCompany(CollUtil.toList(ids));
    }

    @PostMapping("/edit")
    @ApiOperation(value = "生产企业信息编辑", notes = "生产企业信息")
    public Response editProductionCompany(@RequestBody CarProductionCompanyDTO companyDTO) {
        return carProductionCompanyService.editProductionCompany(companyDTO);
    }

    @GetMapping("/list")
    @ApiOperation(value = "车辆产地信息查询", notes = "生产企业信息")
    public Response listProductionCompanyByKeyword(String keyword) {
        return carProductionCompanyService.listProductionCompanyByKeyword(keyword);
    }
}
